package com.rasenhund.android.grecorder.schema;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * ステージ別戦績オブジェクトクラス
 */
public class StageRecord extends Record {

    private String stageNm = "";

    private int totalCount = 0;
    private int winCount = 0;
    private int loseCount = 0;
    private int drawCount = 0;
    
    private String perWin = "-";
    
    public StageRecord() {

    }

    public StageRecord(int stageCd, String StageNm) {

        this.stageCd = stageCd;
        this.stageNm = stageNm;

    }

    public String getStageNm() {
        return stageNm;
    }
    
    public void setStageNm(String stageNm) {
        this.stageNm = stageNm;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getWinCount() {
        return winCount;
    }

    public void setWinCount(int winCount) {
        this.winCount = winCount;
    }

    public int getLoseCount() {
        return loseCount;
    }

    public void setLoseCount(int loseCount) {
        this.loseCount = loseCount;
    }

    public int getDrawCount() {
        return drawCount;
    }

    public void setDrawCount(int drawCount) {
        this.drawCount = drawCount;
    }
    
    public String getPerWin(){
        return perWin;
    }
    
    /**
     * 勝率の計算
     */
    public void calcPerWin(){
        
        if(totalCount != 0){
            BigDecimal dResult;
            dResult = new BigDecimal((float)this.winCount / (float)this.totalCount * 100);
            dResult = dResult.setScale(1, RoundingMode.HALF_UP);
            this.perWin = dResult.toString();
        }else{
            this.perWin = "--.-";
        }
        
    }
    
}
